﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BabyFood.Entities;
using BabyFood.Data;

public partial class Chuyen_Ba_Bau_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            HienThiDinhDuong();
            HienThiDinhDuongall();
            HienThiSucKhoe();
            HienThiSucKhoeall();
            HienThiLamDep();
            HienThiLamDepall();
            InitLinkChude();
        }        
    }

    private void HienThiDinhDuong()
    {
        int TotalRows = 0;
        TList<TinTuc> TList_TinTuc = DataRepository.TinTucProvider.GetPaged("IdSubTinTuc=7 and Tinnong=1", "NgayCapNhat DESC", 0, 1, out TotalRows);

        dldinhduong.DataSource = TList_TinTuc;
        dldinhduong.DataBind();
    }

    private void HienThiDinhDuongall()
    {
        int TotalRows = 0;
        TList<TinTuc> TList_TinTuc = DataRepository.TinTucProvider.GetPaged("IdSubTinTuc=7 and Tinnong=1", "NgayCapNhat DESC", 0, 3, out TotalRows);

        dldinhduongall.DataSource = TList_TinTuc;
        dldinhduongall.DataBind();
    }

    private void HienThiSucKhoe()
    {
        int TotalRows = 0;
        TList<TinTuc> TList_TinTuc = DataRepository.TinTucProvider.GetPaged("IdSubTinTuc=8 and Tinnong=1", "NgayCapNhat DESC", 0, 1, out TotalRows);

        dlsuckhoe.DataSource = TList_TinTuc;
        dlsuckhoe.DataBind();
    }

    private void HienThiSucKhoeall()
    {
        int TotalRows = 0;
        TList<TinTuc> TList_TinTuc = DataRepository.TinTucProvider.GetPaged("IdSubTinTuc=8 and Tinnong=1", "NgayCapNhat DESC", 0, 3, out TotalRows);

        dlsuckhoeall.DataSource = TList_TinTuc;
        dlsuckhoeall.DataBind();
    }

    private void HienThiLamDep()
    {
        int TotalRows = 0;
        TList<TinTuc> TList_TinTuc = DataRepository.TinTucProvider.GetPaged("IdSubTinTuc=9 and Tinnong=1", "NgayCapNhat DESC", 0, 1, out TotalRows);

        dllamdep.DataSource = TList_TinTuc;
        dllamdep.DataBind();
    }

    private void HienThiLamDepall()
    {
        int TotalRows = 0;
        TList<TinTuc> TList_TinTuc = DataRepository.TinTucProvider.GetPaged("IdSubTinTuc=9 and Tinnong=1", "NgayCapNhat DESC", 0, 3, out TotalRows);

        dllamdepall.DataSource = TList_TinTuc;
        dllamdepall.DataBind();
    }

    /// <summary>
    /// Handles ItemDataBound, Binds ExchangesTo to the Child DataList
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void dlFromTrades_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {

            DataListItem parentList = e.Item;
            HiddenField lit_Name = (HiddenField)parentList.FindControl("H_CatalogId");
            string i = (lit_Name.Value).ToString();
            int j = Convert.ToInt32(i);
            int TotalRows = 0;
        }
    }

    public string GetLienKet()
    {
        return Common.sPathUpLienKet;
    }


    public string GetTieuDe(object Char)
    {
        string s = Char.ToString();
        return Common.ConvertToUnSign(s);
    }

    public void InitLinkChude()
    {
        // Dinh dưỡng
        HyperLink32.NavigateUrl = "~/chude/" + "7" + "_" + GetTieuDe("Dinh dưỡng") + ".aspx";
        HyperLink1.NavigateUrl = "~/chude/" + "7" + "_" + GetTieuDe("Dinh dưỡng") + ".aspx";
        // Sức khỏe
        HyperLink4.NavigateUrl = "~/chude/" + "8" + "_" + GetTieuDe("Sức khỏe") + ".aspx";
        HyperLink2.NavigateUrl = "~/chude/" + "8" + "_" + GetTieuDe("Sức khỏe") + ".aspx";
        // Làm đẹp
        HyperLink5.NavigateUrl = "~/chude/" + "9" + "_" + GetTieuDe("Làm đẹp") + ".aspx";
        HyperLink3.NavigateUrl = "~/chude/" + "9" + "_" + GetTieuDe("Làm đẹp") + ".aspx";
    }
}